/*
 * @Author: your name
 * @Date: 2021-08-27 11:06:35
 * @LastEditTime: 2021-08-29 16:59:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day05\3-函数的调用.js
 */

//1.作为参数
//var sayName=function(){}
//function(a,b,fn);

function print(a, b, c) {
    console.log(a, b);
    c();
}
print(100, { name: 'zs' }, function() { console.log("sss") }); //太麻烦
var sayName = function() {
    console.log('say');
    console.log('name');
}
print(100, true, sayName);

//1.函数的应用：对象成员去赋值
//构造函数：Bird  name/color/eat/fly
//函数的传值传的是地址值
function Bird(name, color, ffly) {
    this.name = name;
    this.color = color;
    this.fly = ffly;
}

function fly() {
    console.log('I can fly');
}
var b1 = new Bird('boli', 'red', fly());

//1.参数的应用：绑定监听函数
//2.作为返回值

function foo() {
    return function() {
        console.log('匿名函数');
    }
}

function boo() {
    var sayName = function() {
        console.log(this.name);
    }
    return sayName;
}
var f = foo(); //相当于定义一个函数名为f的函数
var b = boo(); ////相当于定义一个函数名为b的函数
f(); //函数调用
foo()(); //调用
b(); //函数调用
boo()(); //函数调用